import unittest
from api.Ihrm_login_api import IhrmLoginApi
from common.assert_ulit import assert_ulit
from parameterized import parameterized
from common.read_json_util import read_json_data
from config import BASE_DIR


class TestIhrmLogin(unittest.TestCase):
    path_filename = BASE_DIR + "/data/json_data.json"

    # 登录成功
    @parameterized.expand(read_json_data(path_filename))
    def test01_login(self, desc, req_data, stauts_code, success, code, message):
        res = IhrmLoginApi.IhrmLogin(req_data)
        print(desc,":响应结果", res.json())
        # 断言
        assert_ulit(self, res, stauts_code, success, code, message)

    # # 登录成功
    # def test01_login_ok(self):
    #     data = {"mobile": "13800000002", "password": "123456"}
    #     res = IhrmLoginApi.IhrmLogin(data)
    #     print("响应结果", res.json())
    #     # 断言
    #     assert_ulit(self, res, 200, True, 10000, '操作成功！')
    #
    # # 手机号为空
    # def test01_mobile_none(self):
    #     data = {"mobile": None, "password": "123456"}
    #     res = IhrmLoginApi.IhrmLogin(data)
    #     print("响应结果", res.json())
    #     # self.assertEqual(200, res.status_code)
    #     # self.assertEqual(False, res.json().get("success"))
    #     # self.assertEqual(20001, res.json().get("code"))
    #     # self.assertIn('用户名或密码错误', res.json().get("message"))
    #
    #     # 断言
    #     assert_ulit(self, res, 200, False, 20001, '用户名或密码错误')
    #
    # # 密码错误
    # def test01_password_error(self):
    #     data = {"mobile": "13800000002", "password": "12345678"}
    #     res = IhrmLoginApi.IhrmLogin(data)
    #     print("响应结果", res.json())
    #     # self.assertEqual(200, res.status_code)
    #     # self.assertEqual(False, res.json().get("success"))
    #     # self.assertEqual(20001, res.json().get("code"))
    #     # self.assertIn('用户名或密码错误', res.json().get("message"))
    #
    #     # 断言
    #     assert_ulit(self, res, 200, False, 20001, '用户名或密码错误')
